package com.df.springmvc.system.manage.services;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.common.bean.DhtmlGridBean;
import com.common.bean.DhtmlGridFieldBean;
import com.common.util.DhtmlGrid.DhtmlGridAttribuate;
import com.df.springmvc.supper.SupperServices;
import com.df.springmvc.system.manage.dao.SearchDao;

/**
 * 本类只做数据运算处理
 * @author David
 */
@Service
public class SearchServices extends SupperServices{
	@Autowired
	SearchDao dao;
	public List<Object> findAllEmployees(){
		// TODO Auto-generated method stub
		return null; 
	}
	public DhtmlGridBean query(DhtmlGridBean gridBean,HashMap<String,String> param_HashMap) throws Exception{
		// TODO Auto-generated method stub
		Object[] attribute=new Object[]{};
		gridBean.cleanSessionXmlFile();
		DhtmlGridAttribuate attribuate=new DhtmlGridAttribuate();
		attribuate.addFieldBean(new DhtmlGridFieldBean("ck","<center></center>",DhtmlGridFieldBean.TYPE_ED,"0"));
		attribuate.addFieldBean(new DhtmlGridFieldBean("guid","<center></center>",DhtmlGridFieldBean.TYPE_ED,"0"));
		attribuate.addFieldBean(new DhtmlGridFieldBean("projectCode","项目编号",DhtmlGridFieldBean.TYPE_ED,"150",DhtmlGridFieldBean.ALIGN_LEFT));
		attribuate.addFieldBean(new DhtmlGridFieldBean("projectName","项目名称",DhtmlGridFieldBean.TYPE_ED,"240",DhtmlGridFieldBean.ALIGN_LEFT));
		attribuate.addFieldBean(new DhtmlGridFieldBean("packetNum","分包数",DhtmlGridFieldBean.TYPE_ED,"150",DhtmlGridFieldBean.ALIGN_RIGHT));
		attribuate.addFieldBean(new DhtmlGridFieldBean("projectTypeCode","项目类型",DhtmlGridFieldBean.TYPE_ED,"150",DhtmlGridFieldBean.ALIGN_CENTER));
		attribuate.addFieldBean(new DhtmlGridFieldBean("projectModeCode","招标（采购）方式",DhtmlGridFieldBean.TYPE_ED,"150",DhtmlGridFieldBean.ALIGN_LEFT));
		attribuate.addFieldBean(new DhtmlGridFieldBean("batchCode","计划表编号（批文号）",DhtmlGridFieldBean.TYPE_ED,"180",DhtmlGridFieldBean.ALIGN_LEFT));
		attribuate.addFieldBean(new DhtmlGridFieldBean("tenderName","招标（采购）人",DhtmlGridFieldBean.TYPE_ED,"150",DhtmlGridFieldBean.ALIGN_LEFT));
		attribuate.addFieldBean(new DhtmlGridFieldBean("projectStatusCode","项目状态",DhtmlGridFieldBean.TYPE_ED,"120",DhtmlGridFieldBean.ALIGN_CENTER));
		attribuate.addFieldBean(new DhtmlGridFieldBean("guid","<center></center>",DhtmlGridFieldBean.TYPE_ED,"0"));
		attribuate.addFieldBean(new DhtmlGridFieldBean("projectCode","发布状态",DhtmlGridFieldBean.TYPE_ED,"150",DhtmlGridFieldBean.ALIGN_CENTER));
		attribuate.addFieldBean(new DhtmlGridFieldBean("guid","<center></center>",DhtmlGridFieldBean.TYPE_ED,"0"));
		attribuate.addFieldBean(new DhtmlGridFieldBean("projectCode","项目经理",DhtmlGridFieldBean.TYPE_ED,"150",DhtmlGridFieldBean.ALIGN_LEFT));
		attribuate.addFieldBean(new DhtmlGridFieldBean("guid","<center></center>",DhtmlGridFieldBean.TYPE_ED,"0"));
		attribuate.addFieldBean(new DhtmlGridFieldBean("projectCode","项目助理",DhtmlGridFieldBean.TYPE_ED,"150",DhtmlGridFieldBean.ALIGN_LEFT));
		attribuate.addFieldBean(new DhtmlGridFieldBean("createTime","创建时间",DhtmlGridFieldBean.TYPE_ED,"150",DhtmlGridFieldBean.ALIGN_CENTER));
		/**
		 * 增加对应的业务代码
		 */
		ArrayList<Object[]> list=null;
		gridBean.setAttribuate(attribuate);
		param_HashMap.put("userId",getCurrentUserBean().getUserId());
		list=dao.query(param_HashMap,attribute,0,10);
		for(int i=0;i < list.size();i++){
			gridBean.addData(list.get(i));
			if((i + 1) % gridBean.getPageSize() == 0){
				gridBean.createSessionXmlFile();
			}
		}
		gridBean.createSessionXmlFile();
		return gridBean;
	}
	
}
